home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / New System Software Extensions / QuickDraw™ GX v1.0ß2 / Goodies / ColorPicker 2.0a6 / ExamplePicker / Example.h < prev    next >
Encoding:
Text File  |  1992-10-08  |  4.6 KB  |  113 lines  |  [TEXT/MPS ]

  1. /*
  2. *        A sample color picker.
  3. *
  4. *        Written by: Shannon Holland
  5. *        March 2, 1992
  6. *
  7. */
  8.  
  9.  
  10. // this structure defines our private storage block for our "globals"
  11.  
  12. typedef struct PickerStorage
  13. {
  14.     ComponentInstance    myself;
  15.     GrafPtr                port;
  16.     PMColor                color;
  17.     PMColor                origColor;
  18.     long                flags;
  19.     Boolean                visible;
  20.     Boolean                realPicker;
  21.     RGBColor            lastRGB;
  22.     NumFormatString        nFormat;
  23.     NumberParts            nParts;
  24.     short                baseItem;
  25.     Boolean                active;
  26.     PixPatHandle        newColorPat;
  27.     PixPatHandle        origColorPat;
  28.     CMProfileHandle        profile;
  29. } PickerStorage, *PickerStoragePtr, **PickerStorageHndl;
  30.  
  31. // dialog id's
  32.  
  33. #define        iOrigColor    1
  34. #define        iNewColor    2
  35. #define        iRedText    3
  36. #define        iGreenText    4
  37. #define        iBlueText    5
  38. #define        iPrompt        6
  39. #define        iLastItem    6
  40.  
  41. // key id's
  42. #define    kUpArrow        0x1E
  43. #define    kDnArrow        0x1F
  44. #define    kLtArrow        0x1C
  45. #define    kRtArrow        0x1D
  46. #define    kReturn            0xD
  47. #define    kEnter            0x3
  48. #define    kTab            0x9
  49. #define    kBackSpace        0x8
  50.  
  51. // other resource id's
  52. #define    kPercFormatString    4258
  53.  
  54. #define    kPickerDITL            4670
  55.  
  56. #define    kPickerDataType        'pdat'
  57. #define    kPickerData            4660
  58.  
  59. // component manager routines
  60. pascal ComponentResult ExampleMain(ComponentParameters *params, Handle storage);
  61. pascal ComponentResult ExampleOpen(PickerStorageHndl storage, ComponentInstance self);
  62. pascal ComponentResult ExampleClose(PickerStorageHndl storage, ComponentInstance self);
  63. pascal ComponentResult ExampleCanDo(PickerStorageHndl storage, short selector);
  64. pascal ComponentResult ExampleVersion(PickerStorageHndl storage);
  65. pascal ComponentResult ExampleRegister(PickerStorageHndl storage);
  66. pascal ComponentResult ExampleSetTarget(PickerStorageHndl storage, ComponentInstance topOfCallChain);
  67.  
  68. // color picker routines
  69. pascal ComponentResult ExampleInitPicker(PickerStorageHndl storage,PickerInitData *data);
  70. pascal ComponentResult ExampleGetDialog(PickerStorageHndl storage);
  71. pascal long ExampleTestGraphicsWorld(PickerStorageHndl storage,PickerInitData *data);
  72. pascal ComponentResult ExampleGetAttributes(PickerStorageHndl storage);
  73. pascal ComponentResult ExampleGetColor(PickerStorageHndl storage,ColorType whichColor,PMColorPtr color);
  74. pascal ComponentResult ExampleSetColor(PickerStorageHndl storage,ColorType whichColor,PMColorPtr color);
  75. pascal ComponentResult ExampleDoEvent(PickerStorageHndl storage,EventData *data);
  76. pascal ComponentResult ExampleDoEdit(PickerStorageHndl storage,EditData *data);
  77. pascal ComponentResult ExampleSetVisibility(PickerStorageHndl storage,Boolean visible);
  78. pascal ComponentResult ExampleDisplayPicker(PickerStorageHndl storage);
  79. pascal long ExampleItemHit(PickerStorageHndl storage,ItemHitData *data);
  80. pascal long ExampleGetItemList(PickerStorageHndl storage);
  81. pascal long ExampleSetBaseItem(PickerStorageHndl storage,short baseItem);
  82. pascal long ExampleGetProfile(PickerStorageHndl storage);
  83. pascal long ExampleSetProfile(PickerStorageHndl storage,CMProfileHandle profile);
  84. pascal long ExampleGetPrompt(PickerStorageHndl storage,Str255 prompt);
  85. pascal long ExampleSetPrompt(PickerStorageHndl storage,Str255 prompt);
  86. pascal long ExampleGetIconData(PickerStorageHndl storage,PickerIconData *data);
  87. pascal long ExampleGetEditMenuState(PickerStorageHndl storage,MenuState *mState);
  88. pascal long ExampleSetOrigin(PickerStorageHndl storage,Point where);
  89. pascal long ExampleExtractHelpItem(PickerStorageHndl storage,short itemNo,short whichState,HelpItemInfo *helpInfo);
  90.  
  91. // private routines
  92. OSErr DoMouseDown(PickerStorageHndl storage,EventData *data);
  93. OSErr DoKeyDown(PickerStorageHndl storage,EventData *data);
  94. OSErr DoKeyUp(PickerStorageHndl storage,EventData *data);
  95. OSErr DoIdle(PickerStorageHndl storage,EventData *data);
  96. void ActivatePicker(PickerStorageHndl storage);
  97. void DeactivatePicker(PickerStorageHndl storage);
  98. OSErr DoListClick(PickerStorageHndl storage,ItemHitData *data);
  99. void DrawColorList(PickerStorageHndl storage);
  100. void DrawColorEditor(PickerStorageHndl storage,Boolean scrnInvalid);
  101. void SetSelectionColor(PickerStorageHndl storage);
  102. void DrawColorRects(PickerStorageHndl storage,Boolean drawOrig);
  103. void UpdateColorText(PickerStorageHndl storage);
  104. Boolean PtInItem(PickerStorageHndl storage, Point where, short itemNo);
  105. void GetItemRect(PickerStorageHndl storage,short itemNo,Rect *r);
  106. void SetItemRect(PickerStorageHndl storage,short itemNo,Rect *r);
  107. void OffsetItemRect(PickerStorageHndl storage,short itemNo,short h,short v);
  108. void InitNumerics(PickerStorageHndl storage);
  109. void NumToPercentage(PickerStorageHndl storage,long value,char *theString);
  110. Boolean PercentageToNum(PickerStorageHndl storage,char *theString,long *theNum);
  111. Handle GetItemHandle(PickerStorageHndl storage,short theItem);
  112. void CheckCurrentWorld(PickerStorageHndl storage,short itemNo);
  113.